package com.linkgie.galaxyframework.utils;

import java.util.AbstractList;

public class ReadonlyArrayList<T> extends AbstractList<T> {

		private T[] items;
		private int offset;// 开始的位置，包含；
		private int size;

		public ReadonlyArrayList(T[] items, int offset, int size) {
			this.items = items;
			this.offset = offset;
			this.size = size;
		}

		@Override
		public T get(int index) {
			if (index < 0 || index >= size()) {
				throw new IndexOutOfBoundsException();
			}
			return items[offset + index];
		}

		@Override
		public int size() {
			return size;
		}

	}
